package io.geekidea.boot.persmanag.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.geekidea.boot.otherstores.query.total;
import io.geekidea.boot.persmanag.dto.PersManagDto;
import io.geekidea.boot.persmanag.dto.PersManagExcel;
import io.geekidea.boot.persmanag.entity.PersManag;
import io.geekidea.boot.persmanag.query.PersManagQuery;
import io.geekidea.boot.store.entity.Store;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * PersManagMapper 接口
 */
@Mapper
public interface PersManagMapper extends BaseMapper<PersManag> {

    List<PersManag> getpersManagPageList(PersManagQuery persManagQuery);

    total getTotal(PersManagQuery persManagQuery);

    int delById(int id);

    @Select("select id,name from tb_store where areaId = #{id}")
    List<Store> getStoreList(Integer id);

    @Select("select per.*,ar.name areaName,st.name storeName,ro.role roleName from tb_persmanag per left join tb_area ar on ar.id = per.ubietyzone LEFT JOIN tb_store st on st.id = per.ubietyshop LEFT JOIN tb_role ro on ro.id = per.role where per.id = #{id}")
    PersManag getPersManag(Integer id);

    int addPersManag(PersManagDto persManagDto);

    @Update("update tb_persmanag set name = #{name},username =#{username},ubietyzone = #{ubietyZone},ubietyshop=#{ubietyShop},role=#{role},phone=#{phone},whetfordden=#{whetfordden},updatedTime=now(),updatedBy=#{updatedBy} where id = #{id}")
    int updatePersManag(PersManag persManag);


    List<PersManagExcel> getDownloadList(PersManagQuery persManagQuery);

//    int seleById(int id);




}
